from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from changliang import LUJING
from selenium.webdriver.chrome.service import Service

wd = webdriver.Chrome(service=Service(LUJING))
wd.implicitly_wait(5)

wd.get('https://www.byhy.net/cdn2/files/selenium/sample4.html')


from selenium.webdriver.common.action_chains import ActionChains
ac = ActionChains(wd)

time.sleep(3)

# 光标悬停 到元素上
ac.move_to_element(
    wd.find_element(By.CSS_SELECTOR, '.navbar-nav > li.dropdown')
).perform()

time.sleep(3)

# 拖放元素
for i in range(1,6):
    ac.drag_and_drop(
        wd.find_element(By.ID, f'course-{i}'),
        wd.find_element(By.ID,'selected-courses')
    ).perform()

    time.sleep(0.5)

input('\n\n按回车退出')